<?php
if(!defined('ADMINPX') || !defined('ADMIN')) {
	exit('Access Denied');
}
$act=$_GET['act'];
$id=$_GET['id'];
$fid=$_GET['fid'];
$aa=$_GET['aa'];
if($act=='xgtzok'){
    	    if(!$_POST[adminpost]){
	           echo"提交出错<br/>";
	        }elseif($db->update('forum',array('nameys' => $_POST[namey] ,'name' => $_POST[name] ,'content' => $_POST[mm] ,'type_suo' => $_POST[suo] ,'type_jin' => $_POST[jh] ,'cun' => $_POST[tc],'type_din' => $_POST[din])," `id`= '$id'")){
	           echo"修改帖子成功<br/>";
          }else{
		         echo"修改帖子失败<br/>";
          }
          echo "正在自动返回.......<br/><a href=\"admin.php?action=forum_tz&act=xgtz&id=$id&fid=$fid\">请手动返回</a><br/><meta http-equiv=refresh content='3;url=admin.php?action=forum_tz&act=xgtz&&id=$id&fid=$fid'>";
}else if($act=='xgtz'){
   $row=$db->get_one('forum'," `id` ='$id'",'');
   $namee=$user_class->user_name($row[uid]);
   if($row[type_din] == '1'){ $syxsaa="CHECKED "; }else if($row[type_din] == '2'){ $syxsab="CHECKED "; }else if($row[type_din] == '3'){ $syxsac="CHECKED "; }else{ $syxsa="CHECKED "; }
   if($row[type_suo] == '1'){ $ssuob="CHECKED "; }else{ $ssuoa="CHECKED "; }
   if($row[type_jin] == '1'){ $jhb="CHECKED "; }else{ $jha="CHECKED "; }
   if($row[cun] == '1'){ $tcb="CHECKED "; }else{ $tca="CHECKED "; }
echo <<<end
<div class="admin">帖子管理<br/></div>
<form method="POST" action="admin.php?action=forum_tz&act=xgtzok&id=$row[id]&fid=$fid" >
会员： <a href="user-$row[uid].html">$namee</a><br/>
标题：<input class="text" type="text" name="name" value="$row[name]" size=25/><br/>
内容：<br/><textarea  class="dktextarea"  type="text" name="mm" >$row[content]</textarea><br/>
帖子锁帖: 
     <input type="radio" $ssuoa name="suo" value="0" />普通
     <input type="radio" $ssuob name="suo" value="1" />锁帖<br/>
帖子精华: 
     <input type="radio" $jha name="jh" value="0" />普通
     <input type="radio" $jhb name="jh" value="1" />精华<br/>
帖子推存: 
     <input type="radio" $tca name="tc" value="0" />普通
     <input type="radio" $tcb name="tc" value="1" />推存<br/>
帖子置顶: 
     <input type="radio" $syxsa name="din" value="0" />普通
     <input type="radio" $syxsaa name="din" value="1" />本版置顶
     <input type="radio" $syxsab name="din" value="2" />区块置顶
     <input type="radio" $syxsac name="din" value="3" />全坛置顶<br/>
帖子彩色: <input type="text" name="namey" value="$row[nameys]" size=5/>
     <input type="radio" name="namey" value="" />默认
     <input type="radio" name="namey" value="#333333" />黑色
     <input type="radio" name="namey" value="#FF8E44" />红色
     <input type="radio" name="namey" value="#008000" />绿色<br/>
<input class="submit" type="submit" value="提交" name="adminpost" />
</form>
<a href="admin.php?action=forum_tz&act=sctzts&id=$row[id]&fid=$fid">删除帖子</a>
<br/>
<div class="admin">帖子回复<br/></div>
end;
   $num_count=$db->num_rows('forum_hui'," `fid` ='$id' ",'id');
   $list_num ="10";
   $num_start=page_num($list_num,$num_count);
   $sql_bbs  =$db->query('forum_hui'," `fid` ='$id' ORDER BY `id` DESC LIMIT ".$num_start." , ".$list_num." ",'');
   while($row_c=mysql_fetch_array($sql_bbs)){
   	$tcb='';$tca='';
   if($row_c[gl] == '1'){ $tcb="CHECKED "; }else{ $tca="CHECKED "; }
echo <<<end
<div class="admin_a">$row_c[content]
<form method="POST" action="admin.php?action=forum_tz&act=hfpbok&id=$id&hid=$row_c[id]" >
<input type="radio" name="lx" value="0"  $tca />显示
<input type="radio" name="lx" value="1"  $tcb />屏蔽
<input type="submit" value="提交" name="adminpost" />
</form>
</div>
end;
   }
   echo '<div class="bzqczy"></div>'.$page=page_link($list_num,$num_count);

}elseif($act=='hfpbok'){
    	    if(!$_POST[adminpost]){
	           echo"提交出错<br/>";
	        }elseif($db->update('forum_hui',array('gl' => $_POST[lx])," `id`= '$_GET[hid]'")){
	           echo"提交成功<br/>";
          }else{
		         echo"提交失败<br/>";
          }
          echo "正在自动返回.......<br/><a href=\"$url_a\">请手动返回</a><br/><meta http-equiv=refresh content='3;url=$url_a'>";

}else if($act=='sctzts'){
	 echo"注意：删除帖子后直接删除帖子附件及回复！<br/>";
   echo "<a href=\"admin.php?action=forum_tz&act=sctz&id=$id\">确定删除</a><br/>";
}else if($act=='sctz'){
	$sql=$db->query('forum_data'," `cid` ='$id' ORDER BY `id` ","");
	while($row=mysql_fetch_array($sql)){
		   @unlink (Bingz_upload_images('data/forum/'.$row[url].''));
       @unlink('data/forum/'.$row[url].'');
   	   $db->delete('forum_data'," `id` = '$row[id]'");
		   $db->delete('forum_data_user'," `fid` = '$row[id]'");
  }
 	 if($row[type] == '1'){
   	   $db->delete('forum_polloption'," `tid` = '$id'");
   	   $db->delete('forum_polloption_user'," `tid` = '$id'");
   	   $db->delete('forum_hui'," `fid` = '$id'");
   	   $db->delete('forum'," `id` = '$id'");
 	 }else{
   	   $db->delete('forum_hui'," `fid` = '$id'");
   	   $db->delete('forum'," `id` = '$id'");
 	 }
	 echo "删除成功<br/>";
   echo "正在自动返回.......<br/><a href=\"admin.php?action=forum_tz&\">请手动返回</a><br/><meta http-equiv=refresh content='3;url=admin.php?action=forum_tz&'>";
}else if($act=='lttz'){
echo <<<end
<div class="admin">帖子管理<br/></div>
end;
	if($_POST[lt]){
   $num_count=$db->num_rows('forum'," `sz_sc` ='0' AND `cid` ='$_POST[lt]' ",'id');
   $list_num ="10";
   $num_start=page_num($list_num,$num_count);
   $sql_bbs  =$db->query('forum'," `sz_sc` ='0' AND `cid` ='$_POST[lt]' ORDER BY `id` DESC LIMIT ".$num_start." , ".$list_num." ",'');
	}else{
   $num_count=$db->num_rows('forum'," `sz_sc` ='0' ",'id');
   $list_num ="10";
   $num_start=page_num($list_num,$num_count);
   $sql_bbs  =$db->query('forum'," `sz_sc` ='0' ORDER BY `id` DESC LIMIT ".$num_start." , ".$list_num." ",'');
}
$aa=$row_start+1;
while($row_c=@mysql_fetch_array($sql_bbs)){
echo <<<end
<div class="admin_a">$aa 、$row_c[name]
[<a href="admin.php?action=forum_tz&act=xgtz&id=$row_c[id]&fid=$fid">编辑</a>
/ <a href="admin.php?action=forum_tz&act=sctzts&id=$row_c[id]&fid=$fid">删除</a>]<br/></div>
end;
$aa++;
}
  echo '<div class="bzqczy"></div>'.$page=page_link($list_num,$num_count);
}else if($act =='qtzsc'){
         if($_POST['delete']){
            foreach($_POST['delete'] as $val ){
                $db->update('forum',array('sz_sc' => 1 )," `id`= '$val'");
            }
         }
	       echo "提交回收站成功<br/>";	
         echo "正在自动返回.......<br/><a href=\"admin.php?action=forum_tz\">请手动返回</a><br/><meta http-equiv=refresh content='3;url=admin.php?action=forum_tz&'>";
}else{
echo '<div class="admin">帖子管理<br/></div>
<form method="POST" action="admin.php?action=forum_tz&act=lttz" >
快捷进入论坛：<select name="lt">';
	$sql=$db->query('forum_class',"1 ORDER BY `id` ","");
	while($row=mysql_fetch_array($sql)){
echo <<<end
<option value="$row[id]">$row[name]</option>
end;
}
echo <<<end
</select>
<input type="submit" value="进入" name="b1" />
</form>
<div class="admin">最新帖子<br/></div>
<form method="POST" action="admin.php?action=forum_tz&act=qtzsc" >
end;

   $num_count=$db->num_rows('forum'," `sz_sc` ='0' ",'id');
   $list_num ="10";
   $num_start=page_num($list_num,$num_count);
   $sql_bbs  =$db->query('forum'," `sz_sc` ='0' ORDER BY `id` DESC LIMIT ".$num_start." , ".$list_num." ",'');
   $a        =$num_start+'1';
   while($row_c=mysql_fetch_array($sql_bbs)){
$namep='name="delete[]" value="'.$row_c[id].'"';
echo <<<end
<div class="admin_a">$a 、
<input class="checkbox" type="checkbox" $namep />
$row_c[name]
[<a href="admin.php?action=forum_tz&act=xgtz&id=$row_c[id]&fid=$fid">管理</a>
/ <a href="admin.php?action=forum_tz&act=sctzts&id=$row_c[id]&fid=$fid">删除</a>]<br/></div>
end;
      $a++;
   }
   echo '
<input type="checkbox" name="chkall" id="chkallpqwy" class="checkbox" onclick="checkAll(\'prefix\', this.form, \'delete\')" />全拉人回收站?
<input type="submit" value="提交" name="adminpost" />
</form>
   <div class="bzqczy"></div>'.$page=page_link($list_num,$num_count);
}
echo "<a href=\"admin.php?action=forum_tz&\">返回帖子管理</a><br/>";
?>
